---
title: "Reference: Agent | Agents | Kastrax Docs"
description: "Documentation for the Agent class in Kastrax, which provides the foundation for creating AI agents with various capabilities."
---

# Agent ✅

The `Agent` class is the foundation for creating AI agents in Kastrax. It provides methods for generating responses, streaming interactions, and handling voice capabilities.

## Importing ✅

```typescript
import { Agent } from "@kastrax/core/agent";
```

## Constructor ✅

Creates a new Agent instance with the specified configuration.

```typescript
constructor(config: AgentConfig<TAgentId, TTools, TMetrics>)
```

### Parameters
<br />

<PropertiesTable
  content={[
    {
      name: "name",
      type: "string",
      isOptional: false,
      description: "Unique identifier for the agent.",
    },
    {
      name: "instructions",
      type: "string | ({ runtimeContext: RuntimeContext }) => string | Promise<string>",
      isOptional: false,
      description: "Instructions that guide the agent's behavior. Can be a static string or a function that returns a string.",
    },
    {
      name: "model",
      type: "KastraxLanguageModel | ({ runtimeContext: RuntimeContext }) => KastraxLanguageModel | Promise<KastraxLanguageModel>",
      isOptional: false,
      description: "The language model to use for generating responses. Can be a model instance or a function that returns a model.",
    },
    {
      name: "tools",
      type: "ToolsInput | ({ runtimeContext: RuntimeContext }) => ToolsInput | Promise<ToolsInput>",
      isOptional: true,
      description: "Tools that the agent can use. Can be a static object or a function that returns tools.",
    },
    {
      name: "defaultGenerateOptions",
      type: "AgentGenerateOptions",
      isOptional: true,
      description: "Default options to use when calling generate().",
    },
    {
      name: "defaultStreamOptions",
      type: "AgentStreamOptions",
      isOptional: true,
      description: "Default options to use when calling stream().",
    },
    {
      name: "evals",
      type: "Record<string, Metric>",
      isOptional: true,
      description: "Evaluation metrics for assessing agent performance.",
    },
    {
      name: "memory",
      type: "KastraxMemory",
      isOptional: true,
      description: "Memory system for the agent to store and retrieve information.",
    },
    {
      name: "voice",
      type: "CompositeVoice",
      isOptional: true,
      description: "Voice capabilities for speech-to-text and text-to-speech functionality.",
    },
  ]}
/>
